package com.session03;

public class RightTriangle extends Triangle {
    //全局变量
    public double hypotenuse;

    public RightTriangle(int base, int height) {
        //调用父类的构造器，需要使用super
        super(base, height);
        this.hypotenuse = (double) Math.sqrt(base * base + height * height);
        System.out.println("在RightTriangle类的构造器中");
    }

    @Override
    public String toString() {
        //super.toString()是一个字符串无法打印，可以实现赋值打印
        return super.toString() + "右直角三角形的斜边为：" + this.hypotenuse;
    }
}
